package xyz.xtt.equity.constants;

import java.util.concurrent.TimeUnit;

import xyz.xtt.common.starter.cache.CacheConfig;
import xyz.xtt.equity.entity.TblAssetEntitlement;
import xyz.xtt.equity.entity.TblBenefit;
import xyz.xtt.equity.entity.TblBenefitPackage;
import xyz.xtt.equity.entity.TblUserBenefit;
import xyz.xtt.equity.vo.PhoneRegionVo;

/**
 * 缓存类枚举
 * 
 * @author huqibo
 * @date 2024/11/28
 */
public enum AssetCache implements CacheConfig {

	/**
	 * 权益包下的权益列表
	 */
	BENEFIT_LIST_BY_PACKAGE("benefitListByPackage", 3, TimeUnit.HOURS, TblBenefit.class),
	USER_INIT_MINT_BENEFIT("userInitMintBenefit", 1, TimeUnit.DAYS, TblUserBenefit.class),
	/**
	 * 售卖权益包列表
	 */
	BENEFIT_PACKAGE_LIST_BY_CODE("benefitPackageListByCode", 3, TimeUnit.HOURS, TblBenefitPackage.class),
	/**
	 * 售卖权益包
	 */
	BENEFIT_PACKAGE("benefitPackage", 3, TimeUnit.HOURS, TblBenefitPackage.class),
	/**
	 * 售卖权益包
	 */
	BENEFIT_CODE_PACKAGE("benefitCodePackage", 3, TimeUnit.HOURS, TblBenefitPackage.class),
	/**
	 * 赠送次数上限
	 */
	GIFT_LIMT_KEY("giftLimit", 1, TimeUnit.DAYS, Long.class),
	/**
	 * 权益 单条
	 */
	TBL_ASSET_ENTITLEMENT("tblAssetEntitlement", 1, TimeUnit.DAYS, TblAssetEntitlement.class),
	/**
	 * 靓号归属地列表
	 */
	LUCK_PHONE_REGION_LIST("luckPhoneRegionList", 1, TimeUnit.HOURS, PhoneRegionVo.class),
	/**
	 * 售卖权益包
	 */
	BENEFIT_ID_PACKAGE("benefitIdPackage", 3, TimeUnit.HOURS, TblBenefitPackage.class),
	/**
	 * 商家权益类型
	 */
	BUSINESS_BENEFIT_TYPE("businessCastingBenefit", 3, TimeUnit.HOURS, TblBenefitPackage.class),

	;

	/**
	 * 缓存key前缀
	 */
	private String prefix;
	/**
	 * 缓存时长
	 */
	private long ttl;
	/**
	 * 缓存时长单位
	 */
	private TimeUnit timeUnit;
	/**
	 * 缓存序列化对象类型
	 */
	private Class<?> clazz;

	private <T> AssetCache(String prefix, long ttl, TimeUnit timeUnit, Class<T> clazz) {
		this.prefix = prefix;
		this.ttl = ttl;
		this.timeUnit = timeUnit;
		this.clazz = clazz;
	}

	@Override
	public String prefix() {
		return prefix;
	}

	@Override
	public long ttl() {
		return ttl;
	}

	@Override
	public TimeUnit timeUnit() {
		return timeUnit;
	}

	@Override
	public Class<?> clazz() {
		return clazz;
	}

}
